﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace Progetto.Beans
{
    public class User
    {
        private string _email;
        private string _password;
        private List<IRole> _rolesList = new List<IRole>();


        public User(string email, string password, List<IRole> roles)
        {
            _email = email;
            _password = password;
            foreach (IRole role in roles)
            {
                _rolesList.Add(role);
            }
        }

        public User(XmlElement user)
        {
            _email = user.GetAttribute("email");
            _password = user.GetAttribute("password");
            if (user.GetAttribute("friend") == "true")
            {
                XmlElement friendElement = (XmlElement)user.FirstChild;
                Friend friend = new Friend(friendElement);
                _rolesList.Add(friend);
            }
            if (user.GetAttribute("administrator") == "true")
            {
                _rolesList.Add(new Administrator());
            }


        }

        public string Email
        {
            get { return _email; }
            set { _email = value; }
        }

        public string Password
        {
            get { return _password; }
            set { _password = value; }
        }

        internal List<IRole> RolesList
        {
            get { return _rolesList; }
            set { _rolesList = value; }
        }

        //DA METTERE NEL MODEL

        //public void LogIn(string email, string password)
        //{
        //    throw new NotImplementedException();
        //}

        //public void LogOut()
        //{
        //    throw new NotImplementedException();
        //}

    }
}
